<template>
  <el-card>
    <!-- 饼状图 -->
    <div ref="main" class="main2" />
  </el-card>

</template>

<script>
const echarts = require('echarts/lib/echarts')
require('echarts/lib/component/tooltip')
require('echarts/lib/component/legend')
require('echarts/lib/chart/pie')
require('echarts/lib/component/title')
export default {
  mounted() {
    // 实例化图标
    const myChart = echarts.init(this.$refs.main)
    var option

    option = {
      title: {
        text: '公寓免费入住',
        subtext: '还配送女生'
      },
      tooltip: {
        trigger: 'item'
      },
      legend: {
        top: '5%',
        left: '20%'
      },
      series: [
        {
          name: '女多男少',
          type: 'pie',
          radius: ['40%', '70%'],
          center: ['35%', '50%'],
          avoidLabelOverlap: false,
          itemStyle: {
            borderRadius: 10,
            borderColor: '#fff',
            borderWidth: 2
          },
          label: {
            show: false,
            position: 'center'
          },
          emphasis: {
            label: {
              show: true,
              fontSize: '40',
              fontWeight: 'bold'
            }
          },
          labelLine: {
            show: false
          },
          data: [
            { value: 1048, name: '公寓1' },
            { value: 735, name: '公寓2' },
            { value: 580, name: '公寓3' }
          ]
        }
      ]
    }

    option && myChart.setOption(option)
  }
}
</script>

<style lang="scss" scoped>
.el-card{
  margin-left: 10px;
}
.main2{
    width: 600px;
    height: 500px;
}
</style>
